﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace websitev2.Areas.Developer.Controllers
{
    public class TrophyController : Controller
    {
        //
        // GET: /Developer/Trophy/

        public ActionResult Index()
        {
            return View();
        }


        public ActionResult Add()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Add(StartStop.ServiceResources.Trophy oTrophy)
        {
            if (ModelState.IsValid)
            {

                // Add the developerID
                if (Session["DeveloperID"] != null)
                {
                    oTrophy.DeveloperID = Int64.Parse(Session["DeveloperID"].ToString());

                }
                oTrophy.Approved = false;

                StartStop.ServiceResources.MessageResponse oResponse = new StartStop.ServiceResources.MessageResponse();
                oResponse = StartStop.Helpers.Trophy.UpdateTrophy(oTrophy);
                if (oResponse.Success)
                {

                    // Reall this should go to a list of the developers overviews, but since this hasn't been written yet, this will do. 
                    Response.Redirect("/Developer/ControlPanel"); 
                }

            }

            return View(oTrophy);
        }

    }
}
